<!-- 增加课程 -->

<?php require_once 'connect.php'; ?><!-- 连接数据库 -->
<?php 
// 插入课程信息
if ((!empty($_POST['lesson_name']))&&(!empty($_POST['lesson_content']))){
	$query="insert into lessons values(NULL,'".$_POST['lesson_name']."','".$_POST['lesson_content']."')";
	$result=$mysql->query($query);
    if ($result) {
      echo "<script>alert('添加成功！')</script>";
    }else{
      echo "<script>alert('添加失败！')</script>";
    }
} 
 ?>
<button type="button" class="btn btn-lg btn-success btn-block" data-toggle="modal" data-target=".bs-add_lessons-modal-sm">增加课程</button>
<div class="modal fade bs-add_lessons-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div class="modal-content">
	    <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="gridSystemModalLabel">增加课程</h4>
        </div>
       	<form action="./" method="post">
        <div class="modal-body">
	        <div class="form-group">
	          <label>课程名</label>
	          <input type="text" class="form-control" name="lesson_name" placeholder="" required>
	        </div>

	        <div class="form-group">
	          <label>课程内容</label>
	          <textarea class="form-control" rows="5" name="lesson_content" required></textarea>
	        </div>
      	</div>
     	<div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          <button type="submit" class="btn btn-primary">保存</button>
        
        </div>
        </form><!-- 建表 -->
    </div>
  </div>
</div>